  window.onload = function() {
      var url = '/complaint/index';
      var config = {
          elem: '#test',
          url: url,
          cols: [
              [
                  { field: 'id', width: "5%", title: '编号', align: 'center', sort: true },
                  { field: 'sale_type', width: "9%", title: '售后类型', align: 'center' },
                  { field: 'goods_type', width: "10%", title: '货物状态', align: 'center' },
                  { field: 'reason', width: "15%", title: '申请原因', align: 'center' },
                  { field: 'user_name', width: "8%", align: 'center', title: '联系人' },
                  { field: 'user_phone', width: "10%", align: 'center', title: '联系电话' },
                  {
                      field: 'create_time',
                      width: '18%',
                      align: 'center',
                      title: '投诉时间',
                      templet: function(item) {
                          return timestampToTime(parseInt(item.create_time));
                      }
                  },
                  {
                      field: 'status',
                      width: '10%',
                      align: 'center',
                      title: '状态',
                      templet: function(item) {
                          return getComplaintStatus(parseInt(item.status));
                      }
                  },
                  { fixed: 'right', width: "15%", title: '操作', align: 'center', toolbar: '#barDemo' }

              ]
          ],
          page: true
      };

      layui.use(['form', 'layer', 'jquery', 'table', 'laydate'], function() {
          var table = layui.table,
              form = layui.form,
              laydate = layui.laydate,
              layer = parent.layer === undefined ? layui.layer : top.layer,
              $ = layui.jquery;
          table.render(config);
          laydate.render({
              elem: '#start' //指定元素
          });
          laydate.render({
              elem: '#end' //指定元素
          });

          //监听工具条
          table.on('tool(barDemo)', function(obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
              var data = obj.data; //获得当前行数据
              var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
              var tr = obj.tr; //获得当前行 tr 的DOM对象
              if (layEvent === 'detail') { //查看
                  location.href = '/order/get-info?id=' + data.id;
              } else if (layEvent === 'look') {
                  location.href = '/complaint/info?id=' + data.id;
              }
          });
          //搜索
          form.on("submit(serch-form)", function(data) {
              var search_type = $('.search_type option:selected').val();
              var search_value = $("input[name='search_value']").val();
              var status = $('.status option:selected').val();
              var start_time = $('#start').val();
              var end_time = $('#end').val();
              var url = '/complaint/index?search_type=' + search_type + '&search_value=' + search_value + '&status=' + status + '&start_time=' + start_time + '&end_time=' + end_time;
              config.url = url;
              table.render(config);
              return false;
          });
      })
  }